﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ViewModels="clr-namespace:Scripni.Chess.UI.ViewModels">
    <!-- chess square colors -->
    <SolidColorBrush Color="LightGray"
                     x:Key="WhiteSquareBrush"/>
    <SolidColorBrush Color="Brown"
                     x:Key="DarkSquareBrush" />
    
    <!-- chess board list view -->
    <Style TargetType="ListView"
           x:Key="ChessBoardListView">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <UniformGrid Rows="8"
                                 Columns="8" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="ListViewItem">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Color}"
                                     Value="{x:Static ViewModels:SquareColor.Light}">
                            <DataTrigger.Setters>
                                <Setter Property="Background"
                                        Value="{StaticResource WhiteSquareBrush}" />
                            </DataTrigger.Setters>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Color}"
                                     Value="{x:Static ViewModels:SquareColor.Dark}">
                            <DataTrigger.Setters>
                                <Setter Property="Background"
                                        Value="{StaticResource DarkSquareBrush}" />
                            </DataTrigger.Setters>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- chess square data template -->
    <DataTemplate DataType="{x:Type ViewModels:BoardSquareViewModel}">
        <Image Source="{Binding Image}" 
               HorizontalAlignment="Center"
               VerticalAlignment="Center" />
    </DataTemplate>
</ResourceDictionary>